package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;

/**
 * 分析：
 * 问题可以归结为有回路的有向图中寻找回到源点且权最大的回路。
 * 类似Bellman-Ford算法。
 * 注意，只要有一个回路能够产生增益，并且这个回路中至少有一个可达s的节点，就可以套汇。
 * 
 * 实现：
 * 
 * 经验：
 * 
 * 教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P1860 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1860.class.getResource("P1860.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		String[] tmp = line.trim().split("\\s+");
		int N = Integer.valueOf(tmp[0]);
		int M = Integer.valueOf(tmp[1]);
		int S = Integer.valueOf(tmp[2])-1;
		double V = Double.valueOf(tmp[3]);
		
		Edge[] edges = new Edge[2*M];
		for (int i = 0; i < M; i ++) {
			line = stdin.readLine();
			tmp = line.trim().split("\\s+");
			
			int A = Integer.valueOf(tmp[0])-1;
			int B = Integer.valueOf(tmp[1])-1;
			edges[2*i] = new Edge();
			edges[2*i].u = A;
			edges[2*i].v = B;
			edges[2*i].r = Double.valueOf(tmp[2]);
			edges[2*i].c = Double.valueOf(tmp[3]);
			
			edges[2*i+1] = new Edge();
			edges[2*i+1].u = B;
			edges[2*i+1].v = A;
			edges[2*i+1].r = Double.valueOf(tmp[4]);
			edges[2*i+1].c = Double.valueOf(tmp[5]);
		}
		
		System.out.println(check(S, V, N, edges)?"YES":"NO");
	}
	
	private static class Edge {
		
		int u;
		int v;
		double r;
		double c;
	}

	private static boolean check(int S, double V, int N, Edge[] edges) {

		//Bellman-Ford start
		double[] d = new double[N];
		d[S] = V;

		while (d[S] <= V) {

			int relax_flag = 0;
			for (int i = 0; i < edges.length; i ++) {
				Edge e = edges[i];
				double x = (d[e.u] - e.c)*e.r;
				if (x > d[e.v]) {
					d[e.v] = x;
					relax_flag = 1;
				}
			}
			
			if (relax_flag == 0) {	//不能再松弛
				return d[S] > V;
			}
		}
		return true;
	}
}